<template>
	<view class="detail" :style="'background:'+detail.background">
		<view class="cover" @tap="showRule = true">
			<image :src="detail.cover_image" style="height: 370upx;" mode="widthFix"></image>
		</view>
		
		<view class="container" :style="'background:'+detail.background">
			<view class="rule">
				
				<image :src="detail.precautions_image" style="height: 154upx;" mode="widthFix"></image>
			</view>
			
			<view class="qrcode">
				
				<view class="img">
					<image :src="detail.avatar?detail.avatar:detail.icon_image" mode="" class="icon"></image>
					<image :src="'http://qr.liantu.com/api.php?text='+detail.param" mode=""></image>
				</view>
				<view class="name">{{detail.name}}二维码</view>
				<view class="tips" v-if="detail.tips">{{detail.tips}}</view>
			</view>
			
			<view class="video" @tap="toVideo()">
				<view class="icon">
					<image src="../../static/play.png" mode=""></image>
				</view>
				<view class="info">
					<view class="name">{{detail.name}}视频</view>
					<view class="tips">认真学习操作教程 更有利于完成拉新</view>
				</view>
				
			</view>
		</view>
		
		
		<view class="content-box">
			<rich-text :nodes="htmlString"></rich-text>
		</view>
		
		<view class="rule-detail" v-if="showRule">
			<rich-text :nodes="ruleString"></rich-text>
			<view class="close" @tap="showRule = false">关闭</view>
		</view>
	</view>
</template>

<script>
	import Request from '../../common/request.js';
	
	export default {
		data(){
			return {
				id: '',
				detail: {},
				htmlString: '',
				ruleString: '',
				showRule: false,
			}
		},
		onLoad(e) {
			this.id = e.id;
			this.getDetail();
		},
		methods: {
			//获取活动详情
			getDetail() {
				var that = this;
				Request.send({
					url: 'activity/detail',
					data: {id: that.id},
					sCallback: function(res) {
						that.detail = res.data;
						that.htmlString = res.data.content.replace(/\\/g, "").replace(/<img/g, "<img style=\"max-width:100%;display:block;\"");
						that.ruleString = res.data.rule_content.replace(/\\/g, "").replace(/<img/g, "<img style=\"max-width:100%;display:block;\"");
					}
				})
			},
			//去播放视频
			toVideo(){
				var data = {
					url: this.detail.video_file
				}
				uni.navigateTo({
					url:'/pages/activity/video?detailDate=' + encodeURIComponent(JSON.stringify(data))
				})
			}
		}
	}
</script>

<style scoped>
	.cover{
		height: 370upx;
	}
	.cover image{
		width: 750upx;
	}
	
	.rule image{
		width: 100%;
	}
	
	.container{
		padding: 40upx 20upx;
		width: 750upx;
		box-sizing: border-box;
		
	}
	
	.qrcode{
		background: #fff;
		display: flex;
		flex-direction: column;
		justify-content: center;
		width: 100%;
		text-align: center;
		padding: 80upx;
		box-sizing: border-box;
		border-radius: 40upx;
		box-shadow: #fff 0 0 20upx;
	}
	
	.qrcode .img{
		position: relative;
	}
	
	.qrcode .img .icon{
		position: absolute;
		z-index: 99;
		width: 80upx;
		height: 80upx;
		top: 160upx;
		margin: 0 auto;
		left: 0;
		right: 0;
		padding: 8upx;
		background: #fff;
		border-radius: 8upx;
		box-sizing: border-box;
	}
	
	.qrcode image{
		width: 400upx;
		height: 400upx;
	}
	
	.qrcode .name{
		font-size: 40upx;
		font-weight: 600;
		color: #8E492A;
	}
	
	.qrcode .tips{
		color: #B7B7B7;
		margin-top: 20upx;
	}
	
	.video{
		background: #fff;
		display: flex;
		flex-direction: row;
		width: 100%;
		padding: 40upx 20upx;
		box-sizing: border-box;
		border-radius: 40upx;
		box-shadow: #fff 0 0 20upx;
		margin-top: 40upx;
		align-items: center;
	}
	
	
	.video image{
		width: 100upx;
		height: 100upx;
	}
	
	.video .icon {
		margin-right: 20upx;
	}
	
	.video .name{
		font-size: 40upx;
		font-weight: 600;
		color: #8E492A;
		margin-bottom: 20upx;
	}
	
	.video .tips{
		color: #999;
	}
	
	.rule-detail{
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 99;
		padding-bottom: 90upx;
		overflow: scroll;
	}
	
	.rule-detail .close{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 90upx;
		background: #E60012;
		color: #fff;
		text-align: center;
		line-height: 90upx;
		z-index: 100;
	}
	
</style>
